import java.util.Scanner;

public class Work8 {
    public static void main(String[] args) {
        //求2个整数的最大公约数
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int i = a > b ? b : a;
        while (true) {
            if (a % i == 0 && b % i == 0) {
                System.out.println(i);
                break;
            }
            i++;
        }
    }
}
